/*
 * $RCSfile: Column.java,v $
 * $Revision: 1.9 $
 *
 * Comments:
 *
 * (C) Copyright Biuro-Technika 2007.  All rights reserved.
 * THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF Biuro-Technika
 * The copyright notice above does not evidence any
 * actual or intended publication of such source code.
 *
 * $Author: michal $          $Locker:  $
 * $Date: 2010/06/07 12:04:02 $
 * $Log: Column.java,v $
 * Revision 1.9  2010/06/07 12:04:02  michal
 * dodanie Serializable
 *
 * Revision 1.8  2010/04/28 08:07:03  michal
 * poprawa nazwy metody ustawiajacej toString
 *
 * Revision 1.7  2010/04/28 07:52:06  michal
 * poprawka  w equals
 *
 * Revision 1.6  2010/04/28 07:18:00  michal
 * Poprawa konstruktorow
 *
 * Revision 1.5  2009/12/02 12:29:51  michal
 * dodanie metody toString
 *
 * Revision 1.4  2008/10/02 06:44:59  michal
 * dodanie informacji o tym czy kolumna moze posiadac wartosc null
 *
 * Revision 1.3  2008/04/01 12:38:35  muzzy
 * warningi, kosmetyka kodu
 *
 * Revision 1.2  2007/08/24 09:11:29  dominik
 * Dodanie nowych pol i nowych konstruktorow
 *
 * Revision 1.1  2007/08/21 09:21:38  dominik
 * Reprezentacja Kolumny
 *
 */

package parasoft.centrap.migration;

import java.io.Serializable;

public class Column implements Serializable{

	private String columnName;
	private String type;
	private int sqlType;
	private long length;
	private String defaultValue;
	private boolean isPrimaryKey = false;
	private boolean hasIndex;
	private boolean isNotNull = false;
	private String toString = "";
	
	public Column(String name) {
		this.columnName = name;
		this.toString = name;
	}
	
	public Column(String name, String _type) {
		this(name);
		this.type = _type;
	}
	
	public Column(String name, int sqlType, long length, boolean isNotNull, String defaultValue) {
		this(name, sqlType, length, isNotNull);
		this.defaultValue = defaultValue;
		this.isNotNull  = isNotNull;
	}
	
	public Column(String name, int sqlType, long length, boolean isNotNull) {
		this(name);
		this.sqlType = sqlType;
		this.length = length;
		this.isNotNull = isNotNull;
	}

	public String getColumnName() {
		return columnName;
	}

	public boolean isHasIndex() {
		return hasIndex;
	}

	public boolean isPrimaryKey() {
		return isPrimaryKey;
	}

	public String getType() {
		return type;
	}

	public Column setHasIndex(boolean hasIndex) {
		this.hasIndex = hasIndex;return this;
	}

	public Column setType(String type) {
		this.type = type;return this;
	}

	public Column setPrimaryKey(boolean isPrimaryKey) {
		this.isPrimaryKey = isPrimaryKey;return this;
	}
	
	public Column setToString(String newToString){
		this.toString = newToString;return this;
	}

	public int getSqlType() {
		return sqlType;
	}

	public Column setSqlType(int sqlType) {
		this.sqlType = sqlType;return this;
	}

	public long getLength() {
		return length;
	}

	public Column setLength(long length) {
		this.length = length;return this;
	}

	public String getDefaultValue() {
		return defaultValue;
	}

	public Column setDefaultValue(String defaultValue) {
		this.defaultValue = defaultValue;return this;
	}
	
	public boolean isNotNull(){
		return this.isNotNull;
	}
	
	public String toString() {
		return this.toString;
	}
	
	public boolean equals(Object obj) {
		if(obj instanceof Column){
			return columnName.equals(((Column)obj).getColumnName());
		}
		return false;
	}
	
}
